﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CheckPoint>" %>
<%@ Import Namespace="Resources" %>
<%@ Import Namespace="ViewRes" %>
<script type="text/javascript">
    $(function() {
        $(".deleteLink").click(function() {
            deleteEntity(' <%:DiplomaResources.DoYouConfirmDeletion%>', taskDeleted, $(this));
            return false;
        });
    });
</script>
<div class="container" style="border-color: Black; padding: 5px; border-width: 1px;">
    <div><%:Model.StartDate%></div>
    <div class="mediumBoldText"><%:SharedStrings.Name%></div>
    <div ><%:Model.Name%></div>
    <div class="mediumBoldText"><%:SharedStrings.Description%></div>
    <div><%:Model.Description%></div>
    <%
        if (ViewData["LoggedUser"] is Student || ViewData["LoggedUser"] is Lecturer)
        {%>
            <div class="mediumBoldText"><%:SharedStrings.Status%></div>
            <%
            if ((bool)ViewData["CheckpointCompletion"] == true)
            {%>
               <%:SharedStrings.IsCompleted%>
                <%} %>
                <%if ((bool)ViewData["CheckpointCompletion"] == false)
                  {%>
               <%:SharedStrings.NoCompleted%>
           
                <%} %>
<%}
    if (Model is GlobalTask && ViewData["LoggedUser"] is Lecturer && (Model as GlobalTask).CanStatusByLecturerEditing != null && (Model as GlobalTask).CanStatusByLecturerEditing == true)
    {
    %>
                    <a onclick=' editGlobalTaskStatus(this.href, $(this).parents().filter(".container"));return false; '
                     href="<%:Url.RouteUrl("Default",
                                           new {controller = "GlobalTasks", action = "GlobalTaskStatusEdit",globalTaskId = Model.CheckPointId, studentId = ((Student)ViewData["Student"]).UserId})%>">
                    <img class="smallIcon" src="<%:Url.Content("~/Content/Icons/edit.png")%>" title='<%:SharedStrings.Edit%>'/>
                    </a>
  <%} %>
   <% if (ViewData["CompletionDate"] != null && (bool)ViewData["CheckpointCompletion"])
      {%>
    <div><%:(DateTime)ViewData["CompletionDate"]%></div>
     
    <%} %> 
    <div><%:SharedStrings.Necessary%>
    <%
        if (Model.PrevCheckPoint != null)
        {%>
        <%:Model.PrevCheckPoint.Name%>;
     <%
        }
        else
        {%>
      "-" 
      <%
        }%></div>
    <%
        if (Model is GlobalTask && ViewData["LoggedUser"] is SystemManager)
        {%>
      
    <div>
        <span> <a onclick=' editTask(this.href, $(this).parents().filter(".container"));return false; ' 
        href="<%:Url.RouteUrl("Default",
                                           new {controller = "GlobalTasks", action = "Edit", id = Model.CheckPointId})%>">
            <img class="smallIcon" src="<%:Url.Content("~/Content/Icons/edit.png")%>" title='<%:SharedStrings.Edit%>'/>
        </a></span>
        <span> <a href="<%:Url.RouteUrl("Default",
                                           new {controller = "GlobalTasks", action = "Delete", id = Model.CheckPointId})%>" class="deleteLink">
            <img class="smallIcon" src="<%:Url.Content("~/Content/Icons/delete.png")%>" title='<%:SharedStrings.Delete%>'/>
        </a></span>
    </div>
    <%
        } %>    
    <%
        else if (Model is Task && ViewData["LoggedUser"] is Lecturer &&
                 ((Lecturer) ViewData["LoggedUser"]).CanEditTask((Task) Model))
        {%>
    <div>
        <span> <a onclick=' editTask(this.href, $(this).parents().filter(".container"));return false; ' 
        href="<%:Url.RouteUrl("Default",
                                           new {controller = "Tasks", action = "Edit", id = Model.CheckPointId})%>">
            <img class="smallIcon" src="<%:Url.Content("~/Content/Icons/edit.png")%>" title='<%:SharedStrings.Edit%>'/>
        </a></span>
        <span> <a href="<%:Url.RouteUrl("Default",
                                           new {controller = "Tasks", action = "Delete", id = Model.CheckPointId})%>" class="deleteLink">
            <img class="smallIcon" src="<%:Url.Content("~/Content/Icons/delete.png")%>" title='<%:SharedStrings.Delete%>'/>
        </a></span>
    </div>
    <%
        }%>   
</div>